#include<bits/stdc++.h>
#define int long long
#define N 2000005
using namespace std;
int ID,T;
int n,k;
int a[N],b[N];
int sum[N];
int f[5005][5005];
void sol(){
    scanf("%lld %lld",&n,&k);
    int mx=0;
    for(int i=1;i<n;i++) scanf("%lld",&a[i]),mx=max(mx,a[i]);
    a[n]=1e18;
    for(int i=1;i<=k;i++) scanf("%lld",&b[i]);
    for(int i=1;i<=n;i++) sum[i]=0;
    for(int i=1;i<=k;i++){
        sum[i]+=b[i];
        sum[n-k+i+1]-=b[i];
    }
    for(int i=1;i<=n;i++) sum[i]=sum[i]+sum[i-1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=mx;j++) f[i][j]=-1e18;
    }
    for(int i=0;i<=a[1];i++) f[1][i]=sum[1]*i;
    for(int i=1;i<=mx;i++) f[1][i]=max(f[1][i],f[1][i-1]);
    for(int i=2;i<=n;i++){
        for(int j=0;j<=min(a[i-1],a[i]);j++) f[i][j]=j*sum[i]+f[i-1][a[i-1]-j];
        for(int j=1;j<=mx;j++) f[i][j]=max(f[i][j],f[i][j-1]);
    }
    printf("%lld\n",f[n][mx]);
}
signed main(){
    freopen("festival.in","r",stdin);
    freopen("festival.out","w",stdout);
    scanf("%lld %lld",&ID,&T);
    while(T--) sol();
    return 0;
}